package com.lam.smartbutlerv4.service.card;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.CardView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.lam.smartbutlerv4.R;


public class CardFragment extends Fragment {

    private CardView mCardView;
    CallBackValue callBackValue;
    private TextView tv_current_creditlimit;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_adapter, container, false);
        mCardView = (CardView) view.findViewById(R.id.cardView);
        mCardView.setMaxCardElevation(mCardView.getCardElevation()
                * CardAdapter.MAX_ELEVATION_FACTOR);

        tv_current_creditlimit = view.findViewById(R.id.tv_current_creditlimit);
        return view;
    }

    @Override
    public void onAttach(Activity activity) {
        // TODO Auto-generated method stub
        super.onAttach(activity);
        //当前fragment从activity重写了回调接口  得到接口的实例化对象
        callBackValue =(CallBackValue) getActivity();
    }

    public void updateCurrentCreditLimit(String currentCreditLimit) {
//        callBackValue.sendMessageValue(currentCreditLimit);
        tv_current_creditlimit.setText(currentCreditLimit);
    }

    public interface CallBackValue{
        public void sendMessageValue(String strValue);
    }

    public CardView getCardView() {
        return mCardView;
    }
}
